Skip to content

fix(plugin-audit): an activity text names a referenced record by title only to a reader served that title field and admitted to its object - #34653

Merged
objectstack-fleet[bot] merged 13 commits into
mainfrom
claude/sec2-ph96
Nov 17, 2026
Merged

objectstack-fleet[bot] merged 13 commits into
mainfrom
claude/sec2-ph96

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:活动动态(sys_activity)里以标题指称被引用记录的文字——标题字段为查找字段的对象的记录标签、被跟踪查找字段的变更句、里程碑句中的引用占位——只服务给被服务该标题字段、且被准入读取该对象的读者;否则该行不带这段文字,仍带记录 id。目标对象的 API 暴露仍由写入时决定:写入方只为暴露 get 的目标取标题,其余按 id 写入,同一句可一处为标题、一处为 id。
  • 为什么改:加固规则——经活动动态服务给读者的记录标题,遵从该读者的字段级安全;读者读不到的标题不随该行服务、只留记录 id,在标题字段与对象准入两层上与 $expand 的判法一致(referenceNameVisible 只放开对象级拒绝,不放开字段级规则)。
  • 风险与回滚:只收窄读侧服务内容,不改存储、不改写入;能读到所有被引用标题的读者和系统读取不变;回滚即 revert 本 PR,无数据迁移。
  • 先看:packages/plugins/plugin-audit/src/activity-field-redaction.ts(referenceTitlesPerRead 与 redactActivityRows 文本列判定处);packages/plugins/plugin-audit/src/activity-field-redaction.test.ts(末尾两个新 describe);packages/core/src/security/second-object-read-exposure.pin.test.ts(新增的 executes 一行)。
  • 两分钟验证:pnpm --filter @objectstack/plugin-audit exec vitest run src/activity-field-redaction.test.ts,预期 1 个文件、35 个用例全部通过(其中新增 16 个)。
  • 需要你做的:无,席位落地。

What changes

Hardening rule: an activity text that names a referenced record by its title is served only to a reader served that title field and admitted to its object.

An activity row names a referenced record by its title in three places: the record label of an object whose nameField is a lookup or user field, a tracked reference field's change, and a fired milestone's reference token. The sys_activity read redaction (activity-field-redaction.ts) now judges each such text against the object every such reference points at, by the two answers $expand judges a target's title by at that level:

  • the reader must be served the target object's title field (ADR-0079 resolveDisplayField) unmasked, by the same served-fields answer the redaction already uses, which also withholds a formula title computed from a field the reader may not read;
  • and the security service must admit the reader to the target object (canReadObject). A reference field that declares referenceNameVisible lifts this object-level admission and never the field-level rule, as on $expand.

Otherwise the text is left out of the row the way any activity text composed from a field the reader is not served already is, and the row keeps its record_id. A reader served each referenced title field and admitted to each referenced object, and every system read, are served the row as before. The judgement is made at read time from the security service's answers, once per referenced object per read; no row is read for it, and stored rows are judged the same way.

A target's declared API exposure (ADR-0049) stays decided where its title is read: the mirror titles a reference only when the target's exposure serves get (servesSummaryTitleTarget), and names every other referenced record by its stored id, per id, so one sentence can title one reference and name another by its id. The read redaction judges its reader against every reference a sentence names by the two answers above, whatever the target's exposure. The second-object exposure census (packages/core/src/security/second-object-read-exposure.pin.test.ts) classifies the redaction as executing the read audit-writers.ts decides: it reads no record of the target and no title.

The notification door was measured too: an approval notification already names its record by a title its recipient may read, else not at all (a formula title over a withheld field included). This PR adds a door-level pin for it and changes no notification code.

Tests

  • packages/plugins/plugin-audit/src/activity-field-redaction.test.ts, two new top-level describes in the shared harness:
    • a real engine, SQLite driver and the real AuditPlugin mirror, with a security double answering the field members and canReadObject per reader (8 cases): a reader not served the referenced title field, a reader refused the referenced object, referenceNameVisible on each, a tracked reference change, one change naming a target whose exposure serves no get by its id and an exposed target by its title (served to a reader who may read that title, to no reader withheld it), the by-id read, and the control reader;
    • referenceTitlesPerRead directly (8 cases): non-reference sources, every declared reference judged, field and admission halves, referenceNameVisible, fail closed on a throwing admission or an unregistered target, a title-less target, a target whose exposure serves no get judged by the reader like any other, no admission member.
  • packages/core/src/security/second-object-read-exposure.pin.test.ts: activity-field-redaction.ts classified in CALLERS as executes, decided in packages/plugins/plugin-audit/src/audit-writers.ts.
  • Door-level pins on a real boot (bootStack with the real SecurityPlugin):
    • feed door: packages/qa/dogfood/test/activity-label-display-field.dogfood.test.ts, new top-level describe: a reader whose permission set withholds the referenced title field against the control, through GET /data/sys_activity list and by id, armed on the data plane first;
    • notification door: packages/qa/dogfood/test/approval-notification-body.dogfood.test.ts, new top-level describe: two approvers of one request, one withheld a field of the record's formula title, read back from each approver's GET /api/v1/notifications, armed on the data plane first.
  • packages/qa/dogfood/test/lookup-title-exposure.dogfood.test.ts (unchanged) holds the exposure half: a summary names a target whose exposure serves no get by its stored id and the exposed control by its title, for an administrator and a member.

Acceptance notes

  • A changed-fields summary (Updated X "label": Field) that names a changed reference field by its field label also declares that field as a source, so it is left out for a reader refused that reference's title, though the sentence carries no title of the referenced record. The fail-closed direction; noted, not changed.
  • Likewise a sentence naming a target whose exposure serves no get by its id is left out for a reader refused that target's title field or object, though it carries only the id. The fail-closed direction; noted, not changed.
  • Clause-② is no: no input is refused and no accepted set narrows; a reader is served a row without a text column it may not read, the shape every earlier change to this redaction declared.

Verification

All readings at head e2133d6830 (branch claude/sec2-ph96, merged with origin/main), each run under scripts/pm/os-verify-lock.sh.

plugin-audit, core's repo project and the second-object exposure pin
pnpm exec turbo run build --filter='@objectstack/dogfood^...'      -> 70/70 tasks · exit 0
pnpm --filter @objectstack/plugin-audit exec vitest run src/activity-field-redaction.test.ts
                                                                   -> Test Files 1 passed · Tests 35 passed · exit 0
pnpm --filter @objectstack/plugin-audit test                       -> Test Files 101 passed (101) · Tests 1703 passed (1703) · exit 0
pnpm --filter @objectstack/plugin-audit typecheck                  -> exit 0
pnpm --filter @objectstack/core exec vitest run --project repo src/security/second-object-read-exposure.pin.test.ts
                                                                   -> Tests 4 passed (4) · exit 0
pnpm --filter @objectstack/core test:repo                          -> Test Files 8 passed (8) · Tests 105 passed (105) · exit 0
Dogfood: the whole battery, then the touched files and the battery's timed-out files
pnpm --filter @objectstack/dogfood test   (no shard, no path)
 Test Files  4 failed | 474 passed | 3 skipped (481)
      Tests  5 failed | 4053 passed | 68 skipped (4126)

All five failures are Error: Test timed out in 5000ms., in four files outside this diff (bare-name-one-holder-request-family, external-import-walled-catalog-refusal, flow-provenance-server-held, package-commit-revert-path-package), on a shared box under load (the battery held the lock 4035 s). The same four files were run again with the three files this change bears on (lookup-title-exposure, activity-label-display-field, approval-notification-body):

 Test Files  7 passed (7)
      Tests  62 passed (62)
Ablations (earlier rounds; the judged path is unchanged since)
  • The reference-title conjunct in redactActivityRows replaced with true: src/activity-field-redaction.test.ts 5 failed (the engine-level reader cases), then restored, blob == HEAD, git diff HEAD empty.
Gates: derived families, reconciled

node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack at this head: 73 commands, each run, exit code captured before any pipe; --ran reconciliation:

✓ dispatch-gates --ran: 73 derived famil(ies) accounted for — 71 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3).

NOT MEASURED locally, prerequisite not met: check:dual-build-cjs-loads, check:type-check-debt; both run in CI. The derivation does not list core's repo project pin for this diff; it was run explicitly above.


Generated by Claude Code

@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 17, 2026
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/plugin-audit, touching 6 documentable anchor(s).

1 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/permissions/system-context.mdx (via installActivityFieldRedaction (symbol, a top-level function), canReadObject (literal, a string literal in ActivityFieldVisibilitySource))

⛔ 2 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-5.mdx (via canReadObject (literal, a string literal in ActivityFieldVisibilitySource))
  • content/docs/releases/v17/17-6.mdx (via canReadObject (literal, a string literal in ActivityFieldVisibilitySource))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 12 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json f02f4f63707bd05ae2186ca63babd54bfe37abcc → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 4f64bed7ab3548218729c0e301e40cd6fae9bd08 — the merge of head f576d3d0629997ea29a25539eb30dc890ff78aeb into base f02f4f63707bd05ae2186ca63babd54bfe37abcc, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 4f64bed7ab3548218729c0e301e40cd6fae9bd08 && git checkout 4f64bed7ab3548218729c0e301e40cd6fae9bd08
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin f02f4f63707bd05ae2186ca63babd54bfe37abcc f576d3d0629997ea29a25539eb30dc890ff78aeb && git checkout -B drift-repro f02f4f63707bd05ae2186ca63babd54bfe37abcc && git merge --no-ff f576d3d0629997ea29a25539eb30dc890ff78aeb

node scripts/docs-audit/affected-docs.mjs --json f02f4f63707bd05ae2186ca63babd54bfe37abcc

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs f02f4f63707bd05ae2186ca63babd54bfe37abcc → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · os-justin · session_01QSeKYn5CmmdShCJifm6WYj

席位核对

ACCEPT · head 86880c83965748872e179e1ea5ff0da6891159e3 · 2026-11-17T05:57Z

  • Shape: 6 files. Not governed (check-governed-merges --pr 34653: 0 of 6 paths). Clause-②: no, Metadata-protocol: none. Patch for @objectstack/plugin-audit.
  • Review: no contract face, so the seat read the diff itself. An activity text that names a referenced record by its title is served only to a reader who is served that title field, is admitted to the target object, and whose target's declared API exposure serves get. referenceNameVisible lifts only the object-level admission, as on $expand. Otherwise the text is left out and the row keeps its id. A failed object-admission check fails closed.
  • Fix round: the first CI run was red on the second-object exposure pin (security(data, analytics): a lookup target's exposure declaration is not judged when the data door's $expand, or the dataset door's dimension-label pass, reads it — detail withheld pending maintainer #22661). The file is now classified there as a decided read, with a behaviour pin; the pin was run explicitly (4/4).
  • Tests (dev):
    • plugin-audit 1703 passed;
    • core local 3606 and repo 105 passed;
    • the two door pins 8/8;
    • ablations red (5 reference-title cases; 2 exposure cases), then restored.
  • Docs drift: row 45 of system-context.mdx stays true. Its "Lose" list does not yet name the referenced-title judgement; that is a nit, left for the docs owner.
  • Out of this PR, held by the seat: the row-scope half of the reference title, which is a follow-up decision.
  • Check-runs at this head: 56 success, 11 skipped, 0 failed. K = 14.
  • Landing: ready, then the merge queue. The advisory closes on merge.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 17, 2026 05:58
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 17, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⛔ merge queue 构建失败 — 先分诊,再决定要不要重排

队列构建 44027970675 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集),
所以失败的测试可能在本 PR 没碰过的包里 —— 那不是重排能修的。每次盲目重排都会让排在后面的所有 PR 重建一轮。

分类:failure —— 按下面的日志分诊。

失败的 job(日志抽取,best effort):

  • Dogfood Regression Gate (1/3) — 失败步骤: Boot example apps and exercise real user flows

    @objectstack/dogfood:test:  FAIL   isolated  test/lookup-title-exposure.dogfood.test.ts > [#22738] a lookup title is served only for a target whose declared exposure serves `get` > activity (admin): t
      ↳ 失败原因: (这条 FAIL 之后 12 行内没有可识别的原因行 —— 点进 job 看)
    @objectstack/dogfood:test:  FAIL   isolated  test/lookup-title-exposure.dogfood.test.ts > [#22738] a lookup title is served only for a target whose declared exposure serves `get` > activity (member): 
      ↳ 失败原因: @objectstack/dogfood:test: AssertionError: expected '' to contain 'LTEOPEN84'
    

↳ 失败原因 是判读的关键:超时(Test timed out in … / Hook timed out in …)多半是负载/时序,不是本 PR 的回归;
断言(AssertionError: …)才指向真实的行为改变。两者的 FAIL 行长得一模一样,只有这一行能区分。

⚠️ 断言这一侧有一类例外,判据是断言在测什么,不是它是不是 AssertionError。 断言的对象是产品行为(一个值、一个形状、一次拒收)⇒ 照上面读:真实的行为改变,去查,⛔ 不要重排掉;
断言的对象是这次实验自身的有效性前提(跑完的耗时、负载下的先后、任何只在时间预算内才成立的条件)⇒ 它跟超时是同一类,同样对负载敏感,重排一次是合法的判别手段。
识别是机械的:断言的消息或它比较的值本身点名了一段时长、一个时间戳、一个耗时计数。实测过的一对 —— AssertionError: SecurityPlugin.init() ran: expected false to be true 测的是产品行为(真回归);
AssertionError: this run took over a second, so second-precision stamps could have differed too: expected 1006 to be less than 1000 测的是实验前提:它守护的那条不变式当时是绿的,同一个 head 原样重排一次即成功。
穿着 AssertionError 外衣的时间测量,仍然是时间测量。(⛔ 这只改「怎么读一次红」,不改「哪些测试可以重排」——后者由别处管。)

跨 PR 相同签名(24h,按失败测试文件聚合):

历史信号:

  • 本 PR 过去 24h 无队列失败记录(首次)。
  • 过去 24h 队列共有 13 个失败构建(不含本次)。

分诊清单:

  1. 失败测试在本 PR 改动的包里 → 真回归,修 PR。
  2. 失败测试与本 PR 无关 → 看上面的「跨 PR 相同签名」;已有汇总 issue ⇒ flaky/环境问题实锤,去那张 issue 上谈,修好前重排只会再烧一轮全队列。
  3. 两者都不是 → 可能与同组 PR 语义冲突;等前面的 PR 落地或失败出队后再重排一次即可,不要连续重排。

Generated by Claude Code · merge-queue-triage workflow (#4859)

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · os-justin · session_01QSeKYn5CmmdShCJifm6WYj

席位核对

ACCEPT · head f576d3d0629997ea29a25539eb30dc890ff78aeb · 2026-11-17T10:34Z

@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⛔ merge queue 构建失败 — 先分诊,再决定要不要重排

队列构建 44066178950 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集),
所以失败的测试可能在本 PR 没碰过的包里 —— 那不是重排能修的。每次盲目重排都会让排在后面的所有 PR 重建一轮。

分类:failure —— 按下面的日志分诊。

失败的 job(日志抽取,best effort):

  • Test Core (3/10) — 失败步骤: Run this shard's tests

    @objectstack/runtime:test:  FAIL   local  src/domains/meta-disabled-holder-artifact-door.test.ts > [#34040 item 4] the bare doc doors beside two enabled holders of one doc name, 'alpha registered firs
      ↳ 失败原因: @objectstack/runtime:test: AssertionError: {"type":"doc","name":"shared_doc","code":{"name":"shared_doc","label":"alpha doc","content":"# alpha","_packageId":"com.qa.alpha","_packageVersion":"1.0.0","
    @objectstack/runtime:test:  FAIL   local  src/domains/meta-disabled-holder-artifact-door.test.ts > [#34040 item 4] the bare doc doors beside two enabled holders of one doc name, 'beta registered first
      ↳ 失败原因: @objectstack/runtime:test: AssertionError: {"type":"doc","name":"shared_doc","code":{"name":"shared_doc","label":"beta doc","content":"# beta","_packageId":"com.qa.beta","_packageVersion":"1.0.0","_pr
    

↳ 失败原因 是判读的关键:超时(Test timed out in … / Hook timed out in …)多半是负载/时序,不是本 PR 的回归;
断言(AssertionError: …)才指向真实的行为改变。两者的 FAIL 行长得一模一样,只有这一行能区分。

⚠️ 断言这一侧有一类例外,判据是断言在测什么,不是它是不是 AssertionError。 断言的对象是产品行为(一个值、一个形状、一次拒收)⇒ 照上面读:真实的行为改变,去查,⛔ 不要重排掉;
断言的对象是这次实验自身的有效性前提(跑完的耗时、负载下的先后、任何只在时间预算内才成立的条件)⇒ 它跟超时是同一类,同样对负载敏感,重排一次是合法的判别手段。
识别是机械的:断言的消息或它比较的值本身点名了一段时长、一个时间戳、一个耗时计数。实测过的一对 —— AssertionError: SecurityPlugin.init() ran: expected false to be true 测的是产品行为(真回归);
AssertionError: this run took over a second, so second-precision stamps could have differed too: expected 1006 to be less than 1000 测的是实验前提:它守护的那条不变式当时是绿的,同一个 head 原样重排一次即成功。
穿着 AssertionError 外衣的时间测量,仍然是时间测量。(⛔ 这只改「怎么读一次红」,不改「哪些测试可以重排」——后者由别处管。)

跨 PR 相同签名(24h,按失败测试文件聚合):

历史信号:

  • ⚠️ 本 PR 过去 24h 已在队列失败 1 次(不含本次)。 内容未变而反复失败 ⇒ 高度怀疑 flaky 测试或与同组 PR 的语义冲突,重排不解决。
  • 过去 24h 队列共有 21 个失败构建(不含本次)。

分诊清单:

  1. 失败测试在本 PR 改动的包里 → 真回归,修 PR。
  2. 失败测试与本 PR 无关 → 看上面的「跨 PR 相同签名」;已有汇总 issue ⇒ flaky/环境问题实锤,去那张 issue 上谈,修好前重排只会再烧一轮全队列。
  3. 两者都不是 → 可能与同组 PR 语义冲突;等前面的 PR 落地或失败出队后再重排一次即可,不要连续重排。

Generated by Claude Code · merge-queue-triage workflow (#4859)

Merged via the queue into main with commit 1ee3bb8 Nov 17, 2026
108 of 110 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/sec2-ph96 branch November 17, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant